package UIGame;

import java.awt.BorderLayout;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.Label;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Vector;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;

import libarary.Contants.state;

import client.Client;

import xepgach.Game;

public class IUXepGach {

	public JSplitPane split, jsplitchatxg,Jsplitgame;
	private static JFrame jfmain;
	 public Game game = null;
	 Client cl;
	 JList listchat;
	 Vector <String> vchat=new Vector<String>(1,2);
	 public String time="00:00";
	 JLabel Jlbtiem=new JLabel();
	public IUXepGach(Client cl){
		jfmain=new JFrame();
		this.cl=cl;
		game = new Game(this.cl);
		jsplitchatxg = new JSplitPane(JSplitPane.VERTICAL_SPLIT, panelTime(),
				Uichat());
		split=new JSplitPane(JSplitPane.VERTICAL_SPLIT, UIPlayGame(),
				JpanelAvatar());
		
	}
	public JFrame getJFrame(){
		return jfmain;
	}
	public void playgame(){
		jfmain.setLayout(new BorderLayout());
		jfmain.add(split,BorderLayout.CENTER);
		jfmain.add(jsplitchatxg,BorderLayout.EAST);
		jfmain.pack();
		jfmain.setVisible(true);
	}
	public void setvchat(Vector v){
		vchat=v;
		
	}
	public JTabbedPane Uichat() {
	
		listchat=new JList(vchat);
		JTabbedPane jtab=new JTabbedPane();
		JScrollPane ChatScrollPane = new JScrollPane(listchat);
		ChatScrollPane
				.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
		ChatScrollPane
				.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
		
		jtab.add("xephang",ChatScrollPane);
		
		return jtab;
	}
	public JPanel panelTime(){
		JPanel Lg = new JPanel(new BorderLayout());
		Jlbtiem.setText(time);
		Jlbtiem.setFont(new Font("sansserif", Font.BOLD, 24));
		Lg.add(Jlbtiem);
		return Lg;
	}
	public JPanel JpanelAvatar(){
		JPanel Avatar=new JPanel(new BorderLayout());
		Avatar.add(new JLabel(new ImageIcon(".//picture//avatar.png")),BorderLayout.WEST);
		Avatar.add(new Label(cl.nameuser),BorderLayout.EAST);
		return Avatar;
	}
	public JPanel JPcenter(){
		JPanel Lg = new JPanel(new BorderLayout());
		return Lg;
	}
	public JPanel UIPlayGame(){
		JPanel Lg = new JPanel(new BorderLayout());
		Lg.add(game.getComponent(),BorderLayout.CENTER);
		return Lg;
	}
	public JPanel UiGame(){
		JPanel newjp = new JPanel();
		
		return newjp;
	}
	
}
